﻿@model CustomerAddressListModel
@using Nop.Web.Models.Customer;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
@section left
{
    @Html.Action("CustomerNavigation", "Customer", new { selectedTabId = CustomerNavigationEnum.Addresses })
}
<div class="panel panel-default form-panel">
    <div class="panel-heading">
        <h3>@T("Account.MyAccount") - @T("Account.CustomerAddresses")</h3>
    </div>
    <div class="panel-body">
        <div class="address-list">
            @if (Model.Addresses.Count > 0)
            {
                for (int i = 0; i < Model.Addresses.Count; i++)
                {
                    var address = Model.Addresses[i];

                    <div class="section address-item">
                        <div class="title">
                            <strong>@address.FirstName @address.LastName</strong>
                        </div>
                        <ul class="info">
                            <li class="name">
                                @address.FirstName @address.LastName
                            </li>
                            <li class="email">
                                @Html.LabelFor(model => model.Addresses[i].Email, new { }, ":")
                                @address.Email
                            </li>
                            @if (address.PhoneEnabled)
                            {
                                <li class="phone">
                                    @Html.LabelFor(model => model.Addresses[i].PhoneNumber, new { }, ":")
                                    @address.PhoneNumber
                                </li>
                            }
                            @if (address.FaxEnabled)
                            {
                                <li class="fax">
                                    @Html.LabelFor(model => model.Addresses[i].FaxNumber, new { }, ":")
                                    @address.FaxNumber
                                </li>
                            }
                            @if (address.CompanyEnabled && !String.IsNullOrEmpty(address.Company))
                            {
                                <li class="company">@address.Company</li>
                            }
                            @if (address.StreetAddressEnabled)
                            {
                                <li class="address1">
                                    @address.Address1
                                </li>
                            }
                            @if (address.StreetAddress2Enabled && !String.IsNullOrEmpty(address.Address2))
                            {
                                <li class="address2">
                                    @address.Address2
                                </li>
                            }
                            @if (address.CityEnabled || address.StateProvinceEnabled || address.ZipPostalCodeEnabled)
                            {
                                var cityStateZip = "";
                                if (address.CityEnabled)
                                {
                                    cityStateZip = address.City;
                                    if (address.StateProvinceEnabled || address.ZipPostalCodeEnabled)
                                    {
                                        cityStateZip += ",";
                                    }
                                }
                                if (address.StateProvinceEnabled)
                                {
                                    if (!String.IsNullOrEmpty(cityStateZip))
                                    {
                                        cityStateZip += " ";
                                    }
                                    cityStateZip += address.StateProvinceName;
                                }
                                if (address.ZipPostalCodeEnabled)
                                {
                                    if (!String.IsNullOrEmpty(cityStateZip))
                                    {
                                        cityStateZip += " ";
                                    }
                                    cityStateZip += address.ZipPostalCode;
                                }

                                <li class="city-state-zip">
                                    @cityStateZip
                                </li>
                            }
                            @if (address.CountryEnabled && !String.IsNullOrEmpty(address.CountryName))
                            {
                                <li class="country">
                                    @address.CountryName
                                </li>
                            }
                            @if (!String.IsNullOrEmpty(address.FormattedCustomAddressAttributes))
                            {
                                <li class="custom-attributes-view">
                                    @Html.Raw(address.FormattedCustomAddressAttributes)
                                </li>
                            }
                        </ul>
                        <div class="buttons left">
                            <input type="button" class="btn btn-default" onclick="location.href='@(Url.RouteUrl("CustomerAddressEdit", new { addressId = address.Id }))'" value='@T("Common.Edit")' />
                            <input type="button" class="btn btn-default" onclick="if (confirm('@(T("Common.AreYouSure").Text)')) {location.href='@(Url.RouteUrl("CustomerAddressDelete", new { addressId = address.Id }))';}" value="@T("Common.Delete")" />
                        </div>
                    </div>
                }
            }
            else
            {
                @T("Account.CustomerAddresses.NoAddresses")
            }
        </div>
        <hr />
        <div class="add-button">
            <input type="button" class="btn btn-default" onclick="location.href='@Url.RouteUrl("CustomerAddressAdd")'" value="@T("Common.AddNew")" />
        </div>
    </div>
</div>
